package com.zhkj.lib.utils

import android.text.SpannedString
import androidx.core.text.bold
import androidx.core.text.buildSpannedString
import androidx.core.text.scale

/**
 *
 * @author Zachary
 * @date   2020/3/27
 */
object SpanUtil {

    /**
     * 传入金额，拼接人民币符号，并设置符号字体为原字体的60%
     */
    fun setMoneySymbol(price: String, showDivider: Boolean = false) =
        buildSpannedString {
            scale(0.7f) { append("￥") }.append(price)
            if (showDivider) append("/")
        }

    /**
     * 传入金额，生成"xx￥xxx"格式的金额
     */
    fun setPrefixMoneyStr(prefix: String = "赚", price: String): SpannedString =
        buildSpannedString { append(prefix).append("￥").scale(1.2f) { bold { append(price) } } }

    /**
     * 传入金额，生成"xx￥xxx"格式的金额
     */
    fun setPrefixMoneyStr2(prefix: String = "赚", price: String): SpannedString =
        buildSpannedString { append(prefix).scale(1.2f) { bold { append(price) } } }
}